<!--
@description ： 自动加好友任务详情
-->

<template>
  <div v-loading="pageLoading">
    <div class="header-btn">
      <div>详情</div>
      <div>
        <el-button plain type="info" @click="goBack">返回</el-button>
      </div>
    </div>
      <el-form :model="form" :rules="rules" label-suffix=":" label-width="140px" size="medium"
               style="padding-top: 12px">
        <div class="wrap g-card">
          <div class="title-header" style="margin-left: 0">基础信息</div>
          <el-form-item label="任务名称" prop="batchName">
            {{ form.batchName }}
          </el-form-item>
          <el-form-item prop="automateId">
            <template slot="label">
              <span>超级企微:</span>
            </template>
            <div v-for="(item, index) in form.automateId" :key="index">
              {{ item.userName }}
            </div>
          </el-form-item>
          <el-form-item prop="ocLeadNo">
            <template slot="label">
              <span>拓客线索:</span>
            </template>
            <div v-for="(item, index) in form.ocLeadNo" :key="index">
              {{ item.ocLeadName }}
            </div>
          </el-form-item>
          <el-form-item label="任务开始时间" prop="batchType">
            {{ form.batchType == '0' ? '立即发送' : '定时发送' }}
          </el-form-item>
          <el-form-item v-if="form.batchType == '1'" label="发送时间" prop="batchTime">
            {{ form.batchTime }}
          </el-form-item>
        </div>

        <div class="wrap g-card">
          <div class="title-header" style="margin-left: 0">加人设置</div>
          <el-form-item label="每天加人时间" prop="addTime">
            {{showAddTime}}
          </el-form-item>
          <el-form-item label="加人间隔" prop="addInterval">
            <span>每隔{{ form.addInterval[0] }}~{{
                form.addInterval[1]
              }}分钟发送一次请求</span>
          </el-form-item>
          <el-form-item label="请求人数上限" prop="upperLimit">
          <span
            style="font-size: 14px;">每24小时</span>
            {{form.upperLimit}}
            <span
              style="font-size: 14px;">人</span>
          </el-form-item>
          <el-form-item label="验证语" prop="verificationType">
            <el-switch v-model="form.verificationType" disabled active-color="#082aff" inactive-color="#DCDFE6"/>
          </el-form-item>
          <el-form-item v-if="form.verificationType" label="" prop="verificationContent">
            {{ form.verificationContent }}
          </el-form-item>
          <el-form-item label="打标签">
            <el-switch v-model="form.tagType" disabled active-color="#082aff" inactive-color="#DCDFE6"/>
          </el-form-item>
          <el-form-item v-if="form.tagType" label="" prop="label">
            <el-tag v-for="(item, i) in form.customerTag" :key="i" :closable="false" style="margin-bottom: 8px;margin-left:10px"  class="el-tag-tab-group">
              {{ item.groupName + '：' + item.tagName || item.tag }}
            </el-tag>
          </el-form-item>
          <el-form-item label="打备注">
            <el-switch v-model="form.remarkType" disabled active-color="#082aff" inactive-color="#DCDFE6"/>
          </el-form-item>
          <el-form-item v-if="form.remarkType" label="" prop="remark">
            {{ form.remark }}
          </el-form-item>
        </div>
      </el-form>
    </div>
</template>
<script>
import moment from "moment";
import {getAutomateDetail} from "@/api/beathAddAuto";
export default {
  name: "beathAutoTaskDetail", //自动加好友任务详情
  props: {},
  components: {
  },
  data() {
    return {
      form: {
        batchName: '',
        automateId: [],
        ocLeadNo: [],
        batchType: '0',
        batchTime: '',
        addTime: '',
        addInterval: [5, 60],
        upperLimit: 0,
        verificationType: false,
        // verificationContent: [''],
        verificationContent: '',
        tagType: false,
        customerTag: [],
        remarkType: false,
        remark: '',
      },
      rules: {},
      pageLoading: false,
    }
  },
  watch: {},
  computed: {
    showAddTime(){
      return this.form.addTime.replace(/,/g, '-')
    }
  },
  methods: {
    goBack() {
      this.$router.push({
        name: 'Beath',
        query: {
          activeName: '2'
        }
      })
    },
  },
  mounted() {
    if(this.$route.query.batchId){
      this.pageLoading = true
      getAutomateDetail({batchId: this.$route.query.batchId}).then(res => {
        if(res.code == 200){
          let obj = {
            ...res.data,
            verificationType: res.data.verificationType == '0' ? true : false,
            tagType: res.data.tagType == '0' ? true : false,
            remarkType: res.data.remarkType == '0' ? true : false,
            automateId: res.data.automateId ? [{userName: res.data?.userName, automateId: res.data?.automateId, id: res.data?.automateId}] : [],
            ocLeadNo: res.data.ocLeadNo?  [{ocLeadNo: res.data.ocLeadNo, ocLeadName: res.data.ocLeadName}]: [] ,
            addInterval: res.data.addInterval ? JSON.parse(res.data?.addInterval) : '',
            customerTag: res.data.customerTag ? JSON.parse(res.data.customerTag) : [],
            batchType: String(res.data.batchType),
          }
          this.form = obj
          this.$set(this, 'form', obj)
          console.log(this.form, 'form', '123')
        }
        this.pageLoading = false
      }).catch(() => {
        this.pageLoading = false
      })
    }
  },
  created() {
  },
}

</script>

<style lang="scss" scoped>
@import '@/styles/base.scss';

.wrap {
  @include titleWrap;
}

.header-btn {
  @include headerBtn;
}

::v-deep.el-form-item {
  padding: 0 4px;
}

.conIcon {
  font-size: 32px;
  cursor: pointer;
  color: #082aff;
}

::v-deep {
  .el-textarea .el-input__count {
    right: -46px;
    bottom: -5px;
  }
}
</style>
